<script>
  import FileSearch from "@/components/FileSearch.vue";
  import axios from "axios";

  export default {
    components: {
      FileList: FileList,
      FileSearch: FileSearch
    },
    methods: {
      jumpSearch() {
        if (this.$route.path !== "/search")
          this.$router.push("/search")
      },
      jumpList() {
        if (this.$route.path !== "/list")
          this.$router.push("/list")
      },
      logout() {
        axios.get("/api/login/logout").then(resp => {
          this.$router.push("/")
        })
      }
    }
  }
</script>

<template>
  <el-container>
    <el-header style="background: darkgray; height: 60px">Header
      <div style="width: 120px; display: flex; float: right;height: 100%; justify-content: center; align-items: center" @click="logout" id="logout"><span>退出登录</span></div>
    </el-header>
    <el-container>
      <el-aside width="15%" style="background: ghostwhite">
        <el-col :gutter="20">
          <br>
          <div @click="jumpList"><el-row :span="6" class="grid-content bg-purple" justify="center" type="flex" align="middle">文件列表</el-row> </div>
          <br>
          <div @click="jumpSearch"><el-row :span="6" class="grid-content bg-purple" justify="center" type="flex" align="middle">文件搜索</el-row> </div>
          <br>
        </el-col>
      </el-aside>
      <el-main style="padding-top: 0">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<style scoped>
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 40px;
}

.grid-content:hover {
  background: #99a9bf;
  cursor: pointer;
}

.grid-content:active {
  background-color: lightsteelblue;
}

.row-bg {
  padding: 10px 0;
}

#logout:hover {
  background: lightsteelblue;
}
</style>